package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.ConsultAppointment;
import com.hl.sfzy.entity.User;
import com.hl.sfzy.mapper.ConsultAppointmentMapper;
import com.hl.sfzy.service.ConsultAppointmentService;
import com.hl.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ConsultAppointmentServiceImpl
 * @Description TODO
 * @Author Jerry
 * @Date 2024年01月15日 14:12
 * @Version 1.0
 */
@Service("ConsultAppointmentService")
public class ConsultAppointmentServiceImpl implements ConsultAppointmentService {
    @Autowired
    private ConsultAppointmentMapper ConsultAppointmentMapper;
    @Override
    public void add(ConsultAppointment entity) throws Exception {
    ConsultAppointmentMapper.insert(entity);
    }

    @Override
    public void edit(ConsultAppointment entity) {
ConsultAppointmentMapper.update(entity);
    }

    @Override
    public void remove(Integer id) {
ConsultAppointmentMapper.delete(id);
    }

    @Override
    public void removeBatch(Integer[] ids) {
ConsultAppointmentMapper.deleteBatch(ids);
    }

    @Override
    public List<ConsultAppointment> find(ConsultAppointment entity) {

            return ConsultAppointmentMapper.select(entity);
    }

    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ConsultAppointment entity) {
        PageHelper.startPage(pageNum, pageSize);

        List<ConsultAppointment> list = ConsultAppointmentMapper.select(entity); // 当前页数据

        PageInfo<ConsultAppointment> pageInfo = new PageInfo<>(list); // 分页信息对象

        /*
         * 把前台需要的数据反馈
         * 1、当前页面数据（数据列表）
         * 2、此次查询的总记录数
         */
        Map<String, Object> pageMap = new HashMap<>();
        pageMap.put(CommonConstant.PAGE_LIST, list);
        pageMap.put(CommonConstant.PAGE_TOTAL, pageInfo.getTotal());

        return pageMap;
    }

    @Override
    public ConsultAppointment findById(Integer id) {
        return ConsultAppointmentMapper.selectById(id);
    }


    @Override
    public List<ConsultAppointment> findByconsultid(Integer id) {
        return  ConsultAppointmentMapper.selectByGradeid(id);
    }
}
